app.controller("paymethodController",function($scope, $http){
             $http({
                method: 'GET',
                url: '/OA/method/list'
            }).success(function (response) {
                console.log(response)               //总条数
                $scope.total = response.total;
                //反转函数转化abcd转dcba
                $scope.data = response.data.reverse();
                //选择显示的条数
                $scope.values = [{"limit":6}];
                //默认显示的条数
                $scope.selectedLimit=$scope.values[0];
                //默认显示当前页数
                $scope.currentPage = 1;
                if($scope.data != null){
                    $scope.datas = $scope.data.slice($scope.selectedLimit.limit*($scope.currentPage-1),$scope.selectedLimit.limit*$scope.currentPage);
                }else{
                    alert($scope.data);
                }
                $scope.page = {
                "limit":$scope.selectedLimit.limit,"pageSize":5,"pageNo":$scope.currentPage,"totalCount":$scope.total};
                // 2017 /7 /19
                // 定义一个空对象 , 用于更新和保存数据时临时存储
                $scope.prod = {};
                $scope.arrs=response.data;
                console.log($scope.arrs)
                // 定义一个单击删除按钮时触发的事件，用于删除选中行
                 $scope.delete = function($index){
                    if ($index>=0) {
                        if(confirm("是否删除"+$scope.arrs[$index+(($scope.page.pageNo-1)*$scope.page.limit)].name+"的支付方式") ){
                        $scope.arrs.splice($index,1);
                        //将需要删除的卡号传给后台  2017/7/10
                       $http({
                           method:"POST",
                           url:"/OA/method/delete",
                           data:$.param({id:$scope.arrs[$index+(($scope.page.pageNo-1)*$scope.page.limit)].id}),
                           headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
                       }).success(function (result) {
                          if (result.ok==true) {
                             window.location.reload()
                             }
                        })
                      }
                   };
                }
            })
            $scope.change = function(selectedLimit){
                $scope.page.limit = selectedLimit.limit;
                $scope.datas = $scope.data.slice($scope.selectedLimit.limit*($scope.page.pageNo-1),$scope.selectedLimit.limit*$scope.page.pageNo);
            }
            $scope.pageChanged = function(){
                $scope.page.limit = $scope.selectedLimit.limit;
                $scope.datas = $scope.data.slice($scope.selectedLimit.limit*($scope.page.pageNo-1),$scope.selectedLimit.limit*$scope.page.pageNo);
            }
            $scope.setPage = function (go) {
                $scope.length = Math.ceil($scope.total/$scope.selectedLimit.limit);
                console.log($scope.length);
                if(go > $scope.length){
                    $scope.page.pageNo =  $scope.length;
                    console.log($scope.length);
                    
                }else{
                    $scope.page.pageNo=go; 
                }
                $scope.datas = $scope.data.slice($scope.selectedLimit.limit*($scope.page.pageNo-1),$scope.selectedLimit.limit*$scope.page.pageNo);
            };
            $scope.save=function () {
                $http({
                    method:"POST",
                    url:"/OA/method/create",
                    data:$.param({name:$scope.method,service_charge:$scope.poundage,boundary:$scope.boundary,boundaryMoney:$scope.boundaryMoney}),
                    headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
                }).success(function (result) {
                    if (result.ok==true) {
                    $("#studentadd").modal('hide')
                        setTimeout(function () {
                           window.location.reload()
                        },500)
                    }
                })
            }
    });


